﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>

//sizeof
//int main()
//{
//	int a = 10;
//	printf("%zd\n", sizeof(a));
//	printf("%zd\n", sizeof a);
//	printf("%zd\n", sizeof(int));
//
//	return 0;
//}

//strlen
//size_t strlen(const char* str);
//int main()
//{
//	char arr1[3] = { 'a', 'b', 'c' };
//	char arr2[] = "abc";
//	printf("%zd\n", strlen(arr1));
//	printf("%zd\n", strlen(arr2));
//
//	printf("%zd\n", sizeof(arr1));
//	printf("%zd\n", sizeof(arr2));
//	return 0;
//}

//⼀维数组
//int main() {
//	int a[] = { 1,2,3,4 };	
//	printf("%zd\n", sizeof(a));			//16  sizeof(a)取出整个数组的地址
//	printf("%zd\n", sizeof(a + 0));		//4/8   a+0取出首元素地址	
//	printf("%zd\n", sizeof(*a));		//4   取出首元素
//	printf("%zd\n", sizeof(a + 1));		//4/8 取出第二个元素的地址
//	printf("%zd\n", sizeof(a[1]));		//4   取出第二个元素
//	printf("%zd\n", sizeof(&a));		//4/8 取出整个数组的地址，但仍是地址
//	printf("%zd\n", sizeof(*&a));		//16    取出整个数组。
//	printf("%zd\n", sizeof(&a + 1));	//4/8 跳过整个数组，指向数组末尾，是地址
//	printf("%d\n", sizeof(&a[0]));		//4/8 取出首元素地址
//	printf("%d\n", sizeof(&a[0] + 1));	//4/8 取出第二个元素地址
//	return 0;
//}

//字符数组
//int main() {
//	char arr[] = { 'a','b','c','d','e','f' };
//	printf("%zd\n", sizeof(arr));			//6		整个数组长度。
//	printf("%zd\n", sizeof(arr + 0));		//4/8	首元素地址长度
//	printf("%zd\n", sizeof(*arr));			//1		首元素长度	
//	printf("%zd\n", sizeof(arr[1]));		//4/8	第二个元素地址长度
//	printf("%zd\n", sizeof(&arr));			//4/8	取出整个数组地址
//	printf("%zd\n", sizeof(&arr + 1));		//4/8   跳过整个数组，指向数组末位
//	printf("%zd\n", sizeof(&arr[0] + 1));   //4/8	第二个元素的地址
//	return 0;
//}


//int main() {
//	char arr[] = { 'a','b','c','d','e','f' };
//	printf("%zd\n", strlen(arr));			//随机值，从首元素往后找 '\0' ，直到找到为止
//	printf("%zd\n", strlen(arr + 0));		//随机值，从首元素往后找 '\0' ，直到找到为止
//	//printf("%zd\n", strlen(*arr));			//err，取出 'a' ASCII码为97，将97作为地址
//	//printf("%zd\n", strlen(arr[1]));			//err，取出 'b' ASCII码为98，将98作为地址
//	printf("%zd\n", strlen(&arr));			//随机值，从首元素往后找 '\0' ，未找到，取出整个数组地址。
//	printf("%zd\n", strlen(&arr + 1));		//随机值，跳过整个数组，从数组末尾往后找 '\0' ，直到找到为止
//	printf("%zd\n", strlen(&arr[0] + 1));	//随机值，从第二个元素往后找 '\0' ，直到找到为止
//	return 0;
//}

//int main() {
//	char arr[] = "abcdef";
//	printf("%zd\n", sizeof(arr));			//7   取整个数组的大小
//	printf("%zd\n", sizeof(arr + 0));		//4/8 取出首元素地址
//	printf("%zd\n", sizeof(*arr));			//1   首元素大小
//	printf("%zd\n", sizeof(arr[1]));		//1	  第二个元素的大小
//	printf("%zd\n", sizeof(&arr));			//4/8 取出整个数组的地址
//	printf("%zd\n", sizeof(&arr + 1));		//4/8 跳过整个数组，取末尾地址
//	printf("%zd\n", sizeof(&arr[0] + 1));	//4/8 取第二个元素地址
//	return 0;
//}

//int main() {
//	char arr[] = "abcdef";					
//	printf("%zd\n", strlen(arr));			//6			从首元素往后找 '\0'
//	printf("%zd\n", strlen(arr + 0));		//6			从首元素往后找 '\0'
//	//printf("%zd\n", strlen(*arr));			//err
//	//printf("%zd\n", strlen(arr[1]));			//err
//	printf("%zd\n", strlen(&arr));			//6			从首元素往后找 '\0'
//	printf("%zd\n", strlen(&arr + 1));		//随机值	从数组末位往后找'\0'，直到找到为止
//	printf("%zd\n", strlen(&arr[0] + 1));	//5
//	return 0;
//}

//int main() {
//	char* p = "abcdef";
//	printf("%zd\n", sizeof(p));				//4/8
//	printf("%zd\n", sizeof(p + 1));			//4/8
//	printf("%zd\n", sizeof(*p));			//1
//	printf("%zd\n", sizeof(p[0]));			//1
//	printf("%zd\n", sizeof(&p));			//4/8
//	printf("%zd\n", sizeof(&p + 1));		//4/8
//	printf("%zd\n", sizeof(&p[0] + 1));		//4/8
//	return 0;
//}

//int main() {
//	char* p = "abcdef";
//	printf("%zd\n", strlen(p));					//6
//	printf("%zd\n", strlen(p + 1));				//5
//	//printf("%zd\n", strlen(*p));				//err
//	//printf("%zd\n", strlen(p[0]));			//err
//	printf("%zd\n", strlen(&p));			//随机值  &p取得是p的地址，而p中存放的时字符串中首元素地址，和字符串没有关系
//	printf("%zd\n", strlen(&p + 1));			//随机值
//	printf("%zd\n", strlen(&p[0] + 1));			//5
//	return 0;
//}

//int main() {
//	int a[3][4] = { 0 };
//	printf("%zd\n", sizeof(a));				//48
//	printf("%zd\n", sizeof(a[0][0]));		//4
//	printf("%zd\n", sizeof(a[0]));			//16
//	printf("%zd\n", sizeof(a[0] + 1));		//4/8
//	printf("%zd\n", sizeof(*(a[0] + 1)));	//4
//	printf("%zd\n", sizeof(a + 1));			//4/8
//	printf("%zd\n", sizeof(*(a + 1)));		//16
//	printf("%zd\n", sizeof(&a[0] + 1));		//4/8
//	printf("%zd\n", sizeof(*(&a[0] + 1)));	//16
//	printf("%zd\n", sizeof(*a));			//16
//	printf("%zd\n", sizeof(a[3]));			//16
//	return 0;
//}

//int main()
//{
//	int a[5] = { 1, 2, 3, 4, 5 };
//	int* ptr = (int*)(&a + 1);
//	printf("%d,%d", *(a + 1), *(ptr - 1));   //2   5
//	return 0;
//}


//struct Test     
//{
//int Num;
//char* pcName;
//short sDate;
//char cha[2];
//short sBa[4];
//}*p = (struct Test*)0x100000;
//int main()
//{
//	printf("%p\n", p + 0x1);   //0x1000014
//	printf("%p\n", (unsigned long)p + 0x1);  //0x100001
//	printf("%p\n", (unsigned int*)p + 0x1);  //0x100004
//	return 0;
//}

//int main() {
//		int a[3][2] = { (0, 1), (2, 3), (4, 5) };  //1,3,5
//		int* p;
//		p = a[0];
//		printf("%d", p[0]);
//		return 0;
//	}

//int main()
//{
//	int a[5][5];
//	int(*p)[4];
//	p = a;
//	printf("%p,%d\n", &p[4][2] - &a[4][2], &p[4][2] - &a[4][2]);
//	return 0;
//}

//int main()
//{
//	int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
//	int* ptr1 = (int*)(&aa + 1);
//	int* ptr2 = (int*)(*(aa + 1));
//	printf("%d,%d", *(ptr1 - 1), *(ptr2 - 1));    //10,5  
//	return 0;
//}

//int main()
//{
//	char* a[] = { "work","at","alibaba" };
//	char** pa = a;
//	pa++;
//	printf("%s\n", *pa);
//	return 0;
//}

int main()
{
	char* c[] = { "ENTER","NEW","POINT","FIRST" };     
	char** cp[] = { c + 3,c + 2,c + 1,c };
	char*** cpp = cp;
	printf("%s\n", **++cpp);
	printf("%s\n", *-- * ++cpp + 3);
	printf("%s\n", *cpp[-2] + 3);
	printf("%s\n", cpp[-1][-1] + 1);
	return 0;
}